#ifndef FILE_HANDLER_H
#define FILE_HANDLER_H

#include <QObject>
#include <QString>

class QWidget;

class FileHandler : public QObject
{
    Q_OBJECT

public:
    explicit FileHandler(QObject *parent = nullptr);

    void openFile(QWidget *parent = nullptr);
    void saveFile(const QString &filePath, const QString &content);
    void saveAsFile(QWidget *parent, const QString &content);
    QString readFileContent(const QString &filePath);
    bool writeFileContent(const QString &filePath, const QString &content);

signals:
    void fileLoaded(const QString &content, const QString &filePath);
    void errorOccurred(const QString &error);

private:
    QString getFileFilter() const;
};

#endif // FILE_HANDLER_H
